package com.mou.aiagent.agent.model;

import com.mou.aiagent.advisor.MyLoggerAdvisor;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.tool.ToolCallback;
import org.springframework.stereotype.Component;

/**
 * 智能体 mouManus
 */
@Component
public class MouManus extends ToolCallAgent {

    // 构造函数，传入工具数组和聊天模型
    public MouManus(ToolCallback[] allTools, ChatModel dashscopeChatModel) {
        // 调用父类构造函数
        super(allTools);
        // 设置名称
        this.setName("mouManus");
        // 设置系统提示
        String SYSTEM_PROMPT = """  
                You are mouManus, an all-capable AI assistant, aimed at solving any task presented by the user.  
                You have various tools at your disposal that you can call upon to efficiently complete complex requests.  
                """;
        this.setSystemPrompt(SYSTEM_PROMPT);
        // 设置下一步提示
        String NEXT_STEP_PROMPT = """  
                Based on user needs, proactively select the most appropriate tool or combination of tools.  
                For complex tasks, you can break down the problem and use different tools step by step to solve it.  
                After using each tool, clearly explain the execution results and suggest the next steps.  
        // 设置最大步骤数
                If you want to stop the interaction at any point, use the `terminate` tool/function call.  
                """;
        this.setNextStepPrompt(NEXT_STEP_PROMPT);
        this.setMaxStep(20);
        // 初始化客户端
        ChatClient chatClient = ChatClient.builder(dashscopeChatModel)
                .defaultAdvisors(new MyLoggerAdvisor())
                .build();
        this.setChatClient(chatClient);
    }
}
